# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/21 下午5:08
 @Author  : tgy
 
"""

mapping = {}

class RequestMapping:
    __slots__ = ['path', 'method', 'func']

    def __init__(self, path, method='GET'):
        self.path = path
        self.method = method

    def __call__(self, func):
        ...
        self.func = func
        mapping[self.path] = self
        def inner(*args, **kwargs):
            return func(*args, **kwargs)
        return inner


# def requestMapping(path, method='POST'):
#     mapping[path] = RequestMapping(path=path, method=method)
#     return mapping[path]


@RequestMapping(path='/index', method='POST')
def login(username, password):
    ...
    print(username,password)


if __name__ == '__main__':
    ...
    path = '/index'
    if path in mapping:
        mapping[path].func('zhangsan','123456')